<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="/frame/layui/css/layui.css"  media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<form class="layui-form" action="" id="formId">
	  <input name="id" value="${project.id!''}" style="display: none;">
	  <input name="status" value="${project.status!1}" style="display: none;">
	  <fieldset class="layui-elem-field" style="margin: 10px;padding: 5px">
		   	<div class="layui-input-inline" style="width: 100px;padding: 5px;text-align: center;">
		   		<label >项目名称</label>
		   	</div>
		    <div class="layui-input-inline" style="width: 300px;">
		    	<input type="text" name="projectName" id="projectName" value="${project.projectName!}" placeholder="请输入模块名称" class="layui-input">
		    </div>
	  </fieldset>
	  
	  	  <fieldset class="layui-elem-field" style="margin: 10px;padding: 5px">
		   	<div class="layui-input-inline" style="width: 100px;padding: 5px;text-align: center;">
		   		<label >项目简介</label>
		   	</div>
		    <div class="layui-input-inline" style="width: 300px;">
		    	<textarea name="description" id="description" style="project.describe"  placeholder="请输入" class="layui-textarea">${project.description!}</textarea>
		    </div>
	  </fieldset>
	  
	  <fieldset class="layui-elem-field" style="margin: 10px;padding: 5px">
		   	<div class="layui-input-inline" style="width: 100px;padding: 5px;text-align: center;">
		   		<label >协议</label>
		   	</div>
		    <div class="layui-input-inline" style="width: 300px;">
		    	<select name="protocol" >
					<option value="http"  <#if apiInfo??&&(apiInfo.protocol??&&apiInfo.protocol=="http://")>selected="selected" </#if>>http</option>
					<option value="https" disabled <#if apiInfo??&&(apiInfo.protocol??&&apiInfo.protocol=="https://")>selected="selected" </#if>>https</option>
				</select>
		    </div>
	  </fieldset>
	  
	  <fieldset class="layui-elem-field" style="margin: 10px;padding: 5px">
		   	<div class="layui-input-inline" style="width: 100px;padding: 5px;text-align: center;">
		   		<label >IP</label>
		   	</div>
		    <div class="layui-input-inline" style="width: 300px;">
		    	<input type="text" name="ip" id="project.ip" value="${project.ip!}" placeholder="请输入ip" class="layui-input">
		    </div>
		    <div class="layui-input-inline" style="width: 100px;">
		    </div>
	  </fieldset>
	  
	  <fieldset class="layui-elem-field" style="margin: 10px;padding: 5px">
		   	<div class="layui-input-inline" style="width: 100px;padding: 5px;text-align: center;">
		   		<label >port</label>
		   	</div>
		    <div class="layui-input-inline" style="width: 300px;">
		    	<input type="text" name="port" id="project.port" value="${project.port!}" placeholder="请输入port" class="layui-input">
		    </div>
	  </fieldset>
	  <fieldset class="layui-elem-field" style="margin: 10px;padding: 5px">
		   	<div class="layui-input-inline" style="width: 100px;padding: 5px;text-align: center;">
		   	</div>
		    <div class="layui-input-inline" style="width: 300px;">
				<div class="layui-form-mid layui-word-aux">*协议 IP port 当你添加API接口的时候 默认填入 </div>
			</div>
	  </fieldset>
	   <fieldset class="layui-elem-field" style="margin: 10px;padding: 5px">
		   	<div class="layui-input-inline" style="width: 100px;padding: 5px;text-align: center;">
		   		<label ></label>
		   	</div>
		    <div class="layui-input-inline" style="width: 300px;">
				<input class="layui-btn" onclick="saveOrEdit()" type="button" value="${buttonName!'提交'}">
			</div>
	  </fieldset>

	  
</form>
<script type="text/javascript" src="/js/jquery-1.4.4.min.js"></script>
<script src="/frame/layui/lay/dest/layui.all.js" charset="utf-8"></script>
<!-- 模板引擎 -->
<script src="/js/template/template.js" charset="utf-8"></script>
<script src="/js/template/templateUtil.js" charset="utf-8"></script>
<script type="text/javascript">
function msg(msg,id){
	layer.tips(msg, id, {
		  tips: [1, '#0FA6D8'] //还可配置颜色
	});
	$(id).focus();
}
function boolParam(){
	if(isNull($("#projectName").val())){
		msg("不能为空","#projectName");
		return false;
	}
	if(isNull($("#description").val())){
		msg("不能为空","#description");
		return false;
	}
	return true;
}


	function saveOrEdit(){
		//参数校验
		if(!boolParam()){
			return;
		}
		var project = $("#formId").serializeArray();
		$.ajax({
            type: "POST",
            url: "${basePath}/project/doSaveOrEdit",
            data: project,
            dataType: "json",
            success: function(data){
            	if(data.isSuccess){
            		layer.msg(data.message,{time: 500});
            		
            		window.setTimeout(function(){
            			var index = parent.layer.getFrameIndex(window.name); 
                		parent.layer.close(index);
            		},500); 

            	}else{
            		layer.msg(data.message,{time: 3000});
            	}
            },
            error: function(data){
            	layer.msg("网络错误！");
            }
        });
	}
	
	
</script>
</body>
</html>
